home *** CD-ROM | disk | FTP | other *** search
- /*
- ** TEXT COMPARE UTILITY
- **
- ** Copyright 1988-89, S.E. Margison
- **
- ** Modified 1989 by Bob Stout
- **
- ** This short utility compares two text files and shows
- ** any line differences.
- **
- ** As distributed, this program requires (for compilation):
- ** "The MicroFirm Function LIbrary for MS/QC"
- ** which may be obtained without registration from many Bulletin
- ** Board Systems.
- **
- ** or by registration:
- ** $25 for Docs, C, S, M, L, H libraries, and complete library source
- ** in C and Assembler
- ** MicroFirm
- ** P.O. Box 428
- ** Alief, TX 77411
- **
- **
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <mflstrng.h>
- #include <mflsys.h>
- #include <mflfiles.h>
-
- #define MAXLINE 192
-
- FILE *fp1, *fp2;
- char buf1[MAXLINE], buf2[MAXLINE];
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int lc, end1, end2;
- lc = 0;
- end1 = end2 = FALSE;
-
- if(argc != 3)
- error("usage: TC file1 file2");
-
- if((fp1 = fopen(argv[1], "r")) == NULL) cant(argv[1]);
-
- if((fp2 = fopen(argv[2], "r")) == NULL)
- {
- fclose(fp1);
- cant(argv[2]);
- }
-
- for EVER
- {
- ++lc;
- if(fgets(buf1, MAXLINE, fp1) == NULL)
- end1 = TRUE;
- if(fgets(buf2, MAXLINE, fp2) == NULL)
- end2 = TRUE;
- if(end1 || end2)
- break;
-
- if(strcmp(buf1, buf2))
- {
- printf("Line %d in %s\n", lc, argv[1]);
- printf("%s", buf1);
- printf("Line %d in %s\n", lc, argv[2]);
- printf("%s", buf2);
- }
- }
- if(end1 && !end2)
- printf("EOF on %s occured first\n", argv[1]);
- if(end2 && !end1)
- printf("EOF on %s occured first\n", argv[2]);
- fclose(fp1);
- fclose(fp2);
- }
-